<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>华为商城</title>
</head>
<body>
<div id="appl">
<P>用户名：<input type="text" placeholder="用户名" v-model="users.username"></P>
<p>密码：<input type="password" placeholder="密码" v-model="users.password"></p>
    <input type="button" value="注册" @click="login">
</div>
</body>
</html>
<script type="text/javascript" src="js/vue.js"></script>
<script type="text/javascript" src="js/axios.min.js"></script>
<script>
    var app = new Vue({
        // 监控内容
        el: "#appl",
        data: {
            users: {}
        },
        methods: {
            login: function () {
                axios.post("http://localhost/huawei/users/regist", this.users).then(res => {
                    console.log(res.data.status);
                    if (res.data.status){
                        alert("已经注册成功，点击确定进行登录");
                        location.href="/huawei/index.html";
                    }else {
                        console.log(res.data.msg);
                    }
                });
                // axios.post("http://localhost/huawei/users/regist", this.users).then(res => {
                //     // console.log(res.data);
                //     if (res.data.status) {
                //         //浏览器存储信息
                //         localStorage.setItem("users", JSON.stringify(res.data.userDB));
                //         // 跳转到首页
                //         location.href = "/huawei/index.html";
                //     } else {
                //         alert(res.data.meg);
                //     }
                //
                // });
            }
        }
    });
</script>

